package com.wangxin.study8.threadtest;

/**
 * @author jojo.wang
 * @title: JoinTest
 * @projectName study8
 * @description: 当我们调用某个线程的这个方法时，这个方法会挂起调用线程，直到被调用线程结束执行，调用线程才会继续执行。
 * @date 2019/5/715:45
 */

public class JoinTest {
    public static void main(String[] args) throws Exception{
        Thread t1 = new Thread(new JoinThread());
        Thread t2 = new Thread(new JoinThread());
        t1.start();
        t1.join();
        System.out.println("1执行完成");
        t2.start();
        System.out.println("2执行完成");
        t2.join();
        System.out.println("全部执行完成");
    }
}
class JoinThread implements Runnable{

    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            System.out.println(Thread.currentThread().getName());
        }
    }
}
